/*
 *         Copyright (c), NXP Semiconductors Bangalore / India
 *
 *                     (C)NXP Semiconductors
 *       All rights are reserved. Reproduction in whole or in part is 
 *      prohibited without the written consent of the copyright owner.
 *  NXP reserves the right to make changes without notice at any time.
 * NXP makes no warranty, expressed, implied or statutory, including but
 * not limited to any implied warranty of merchantability or fitness for any
 *particular purpose, or that the use will not infringe any third party patent,
 * copyright or trademark. NXP must not be liable for any loss or damage
 *                          arising from its use.
 */

/** \file
 * Rc523 communication functions for SamAV3 in X-Mode configuration.
 * $Author: nxp60813 $
 * $Revision: 124 $
 * $Date: 2013-04-22 12:10:31 +0530 (Mon, 22 Apr 2013) $
 *
 * History:
 *  CHu: Generated 19. May 2009
 *
 */

#ifndef PHHALHW_SAMAV3_RC_523_H
#define PHHALHW_SAMAV3_RC_523_H

#include <ph_Status.h>

/** \addtogroup ph_Private
 *  @{
 */

#define PHHAL_HW_SAMAV3_RC523_TIMER_FREQ							13.56f	/**< RC internal timer frequency */
#define PHHAL_HW_SAMAV3_RC523_ETU_106								9.44f	/**< Duration of one ETU at 106 kBit/s in [us] */

#define PHHAL_HW_SAMAV3_RC523_TIMER_MAX_VALUE_US					6596996	/**< (RC523) Maximum timer value in microseconds. */
#define PHHAL_HW_SAMAV3_RC523_TIMER_SHIFT							4.8f	/**< (RC523) Shift of the internal RC timer in ETUs. */

/**
 * \brief Set configuration parameter.
 *
 * <b> Rc523 Specific </b>
 *
 * \return Status code
 * \retval #PH_ERR_SUCCESS Operation successful.
 * \retval #PH_ERR_UNSUPPORTED_PARAMETER Configuration is not supported or invalid.
 * \retval #PH_ERR_INVALID_PARAMETER Parameter value is invalid.
 * \retval #PH_ERR_PARAMETER_OVERFLOW Setting the parameter value would lead to an overflow.
 * \retval #PH_ERR_INTERFACE_ERROR Communication error.
 */
phStatus_t phhalHw_SamAV3_Rc523_SetConfig(
		phhalHw_SamAV3_DataParams_t * pDataParams,							/**< [In] Pointer to this layer's parameter structure. */
		uint16_t wConfig,													/**< [In] Configuration Identifier. */
		uint16_t wValue														/**< [In] Configuration Value. */
	);

/**
 * \brief Blocks until the time given by \b wTimeout elapsed.
 *
 * <b> Rc523 Specific </b>
 *
 * \return Status code
 * \retval #PH_ERR_SUCCESS Operation successful.
 * \retval #PH_ERR_INVALID_PARAMETER \b bUnit is invalid.
 * \retval #PH_ERR_INTERFACE_ERROR Communication error.
 */
phStatus_t phhalHw_SamAV3_Rc523_Wait(
		phhalHw_SamAV3_DataParams_t * pDataParams,							/**< [In] Pointer to this layer's parameter structure. */
		uint8_t bUnit,														/**< [In] Unit of given timeout value (either #PHHAL_HW_TIME_MICROSECONDS or #PHHAL_HW_TIME_MILLISECONDS). */
		uint16_t wTimeout													/**< [In] Timeout value. */
	);

/**
 * \brief Sets the Frame Delay Time (Timeout).
 *
 * <b> Rc523 Specific </b>
 * \b Note: Frame Delay Time is defined between the last transmitted bit and the first received bit.
 *
 * \return Status code
 * \retval #PH_ERR_SUCCESS Operation successful.
 * \retval Other Depending on implementation and underlaying component.
 */
phStatus_t phhalHw_SamAV3_Rc523_SetFdt(
		phhalHw_SamAV3_DataParams_t * pDataParams,							/**< [In] Pointer to this layer's parameter structure. */
		uint8_t bUnit,														/**< [In] Unit of given timeout value (either #PHHAL_HW_TIME_MICROSECONDS or #PHHAL_HW_TIME_MILLISECONDS). */
		uint16_t wTimeout													/**< [In] Timeout value. */
	);

/**
 * \brief Retrieves the Frame Delay Time of the last command.
 *
 * <b> Rc523 Specific </b>
 * \b Note: Frame Delay Time is defined between the last transmitted bit and the first received bit.
 *
 * \return Status code
 * \retval #PH_ERR_SUCCESS Operation successful.
 * \retval Other Depending on implementation and underlaying component.
 */
phStatus_t phhalHw_SamAV3_Rc523_GetFdt(
		phhalHw_SamAV3_DataParams_t * pDataParams,							/**< [In] Pointer to this layer's parameter structure. */
		uint32_t * pTime													/**< [Out] Calculated time in microseconds from timer contents. */
	);

/** @}
 * end of ph_Private group
 */

#endif /* PHHALHW_SAMAV3_RC_523_H */
